package com.zeroup.auto.assists.step.unify;

import android.graphics.Path;

import androidx.annotation.NonNull;

import com.ven.assists.Assists;
import com.ven.assists.AssistsWindowManager;
import com.zeroup.auto.assists.DouYinBaseStep;
import com.zeroup.auto.assists.next.StepBeanData;
import com.zeroup.auto.utils.AssistsUtils;
import com.ven.assists.stepper.StepCollector;
import com.ven.assists.stepper.StepData;

import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;

/**
 * 屏幕滚动
 */
public class ScreenRollingStep extends DouYinBaseStep {




    @Override
    public void onImpl(@NonNull StepCollector stepCollector) {
        stepCollector.next(1,false,(i,c)->{
            Object serviceData = AssistsUtils.getServiceData(i.getData());
            if(serviceData==null){
                return AssistsUtils.nextStep( i.getData());
            }
            Path mPath=new Path();//线性的path代表手势路径,点代表按下,封闭的没用
            if(serviceData instanceof StepBeanData){
                StepBeanData stepBeanData = (StepBeanData)serviceData;
                AssistsWindowManager.INSTANCE.switchNotTouchableAll();
                if(stepBeanData.getAcType()==1) {//下滑
                    mPath.moveTo(500, 400);
                    mPath.lineTo(500, 1000);
                    Assists.gesture(mPath, 0L, 300L, (Continuation<? super Unit>) this);
                }else if(stepBeanData.getAcType()==2) {//上滑
                    mPath.moveTo(500, 1000);
                    mPath.lineTo(500, 400);
                    Assists.gesture(mPath,0,300, (Continuation<? super Unit>) this);
                }else if(stepBeanData.getAcType()==3) {//左滑
                    mPath.moveTo(600, 500);
                    mPath.lineTo(0, 500);
                    Assists.gesture(mPath,0,300, (Continuation<? super Unit>) this);
                }else if(stepBeanData.getAcType()==4){//右滑
                    mPath.moveTo(0, 500);
                    mPath.lineTo(600, 500);
                    Assists.gesture(mPath,0,300, (Continuation<? super Unit>) this);
                }
                AssistsWindowManager.INSTANCE.switchTouchableAll();
            }
            return AssistsUtils.nextStep(i.getData());
        });
    }
}
